home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MENU_UTL / TPPDMENU / TPPDMOUS.PAS < prev   
Pascal/Delphi Source File  |  1990-01-11  |  4KB  |  126 lines

  1. {$S-,R-,V-,I-,B-,F-}
  2.  
  3. {$IFDEF Ver40}
  4.   {$F-}
  5. {$ELSE}
  6. {$F+}
  7. {$O-}
  8. {$ENDIF}
  9.  
  10. {$IFDEF Debug}
  11.   {$D+}
  12. {$ENDIF}
  13.  
  14. {Conditional defines that may affect this unit}
  15. {$I TPDEFINE.INC}
  16.  
  17. {*********************************************************}
  18. {*                  TPPDMOUS.PAS 5.06                    *}
  19. {*          Copyright (c) Ken Henderson 1989, 1990.      *}
  20. {*                                                       *}
  21. {*                                                       *}
  22. {*                                                       *}
  23. {*********************************************************}
  24.  
  25. unit TpPdMous;
  26.   {-Mouse support for TpPdMenu.}
  27.  
  28.  
  29. interface
  30.  
  31. uses
  32.   TpCrt,                          {Turbo Professional CRT unit}
  33.   Dos,                            {DOS interface - standard unit}
  34.   TpMouse,                        {Turbo Professional mouse routines}
  35.   TpInline;
  36.  
  37. var
  38.   MouseWasMoved            : Boolean;
  39.   SaveInt33                : Pointer;
  40.   CmdStringWord            : Word;
  41.   MouseWasX, MouseWasY, MouseIsX, MouseIsY, MouseSenX, MouseSenY, SlowMouseSenX, SlowMouseSenY : Byte;
  42.  
  43. const
  44.   MStatus                  : ButtonStatus = NoButton;
  45.  
  46. procedure AllPurposeEventHandler;
  47.   {-Event handler}
  48.  
  49. procedure InitMouseSettings;
  50.   {-Reinitializes mouse and sets MouseInstalled}
  51.  
  52.   {==========================================================================}
  53.  
  54. implementation
  55.  
  56. var
  57.   MousePosX, MousePosY     : Byte;
  58.   Ch                       : Char;
  59.  
  60.   procedure AllPurposeEventHandler;
  61.   begin
  62.     MouseWasX := MouseIsX;
  63.     MouseWasY := MouseIsY;
  64.     MouseWhereXY(MouseIsX, MouseIsY, MStatus);
  65.     if MouseIsY > MouseWasY then StuffKey($5000);
  66.     if MouseIsY < MouseWasY then StuffKey($4800);
  67.     if MouseIsX > MouseWasX then StuffKey($4D00);
  68.     if MouseIsX < MouseWasX then StuffKey($4B00);
  69.     if MStatus <> NoButton then
  70.     begin
  71.       case MStatus of
  72.         LeftButton :
  73.         begin {Left button}
  74.                        StuffKey($000D); {Insert <Enter>}
  75.                      end;
  76.         RightButton :
  77.         begin {Right button}
  78.                         StuffKey($001B); {Insert <Esc>}
  79.                       end;
  80.         BothButtons..All3Buttons :
  81.           begin                   {Insert <F1>}
  82.             StuffKey($3B00);
  83.           end;
  84.       end;
  85.     end;
  86.     if (MouseIsX = Succ(MouseXLo)) or (MouseIsX = MouseXHi) or
  87.     (MouseIsY = Succ(MouseYLo)) or (MouseIsY = MouseYHi) then
  88.     begin
  89.       MouseWasX := 40;
  90.       MouseWasY := 12;
  91.       MouseIsX := MouseWasX;
  92.       MouseIsY := MouseWasY;
  93.       MouseGotoXy(MouseWasX, MouseWasY);
  94.     end;
  95.   end;
  96.  
  97.   procedure InitMouseSettings;
  98.   var
  99.     strnum                   : String;
  100.     num, res                 : Integer;
  101.     MouseCharacter           : Byte;
  102.   begin
  103.     {no need to install exit handler if not installed}
  104.     if MouseInstalled then
  105.     begin
  106.       FullMouseWindow;
  107.       MouseWasX := 40;
  108.       MouseWasY := 12;
  109.       MouseIsX := MouseWasX;
  110.       MouseIsY := MouseWasY;
  111.       MouseSenX := 8;
  112.       MouseSenY := 24;
  113.       SlowMouseSenX := 88;
  114.       SlowMouseSenY := 48;
  115.       MouseGotoXy(MouseWasX, MouseWasY);
  116.       SetMickeyToPixelRatio(SlowMouseSenX, SlowMouseSenY);
  117.       SetMouseEventHandler(AllMouseEvents, @AllPurposeEventHandler);
  118.     end;
  119.   end;
  120.  
  121. begin
  122.   GetIntVec($33, SaveInt33);      {Save off the mouse interrupt}
  123.   {initialize the mouse if one is installed (sets MouseInstalled)}
  124.   if MouseInstalled then InitMouseSettings;
  125. end.
  126.